import { PlayerDialog } from "./PlayerDialog";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { EventName } from "../../../mvc/EventName";
import { DataEvent } from "../../../events/DataEvent";
import { Cache } from "../../../cache/Cache";
import { Language } from "../../../../../extend/language/Language";
import { RemainTimeTool } from "../../award/RemainTimeTool";
//class EatParadeTimeCount
    
    export  class EatParadeTimeCount extends PlayerDialog
    {
        constructor()
        {
            super();
            this.initUI();
            return;
        }

        /* internal  */initUI(): void
        {
            this._startTime = ObjCreate.createTextField("", 0, 0, 100, 20, this, GlobalStyle.textFormat1, true, false);
            return;
        }

        public initData(): void
        {
            Dispatcher.addEventListener(EventName.OnEatParadeStartTimeCount, this.onActiveTimeUpdate);
            return;
        }

        /* internal  */onActiveTimeUpdate(arg1: DataEvent): void
        {
            if (Cache.instance.dialog.eatParadeApplyProcess == 1 || int(arg1.data) > 0) 
            {
                this._str = Language.getStringByParam(200103, RemainTimeTool.getRemainTimeBySeconds(int(arg1.data), true, true));
            }
            else 
            {
                this._str = "";
            }
            this._startTime.htmlText = this._str;
            return;
        }

        public /* override */ dispose(): void
        {
            super.dispose();
            this._startTime.text = "";
            Dispatcher.removeEventListener(EventName.OnEatParadeStartTimeCount, this.onActiveTimeUpdate);
            return;
        }

        /* internal */ /* var */_startTime: Object /* flash.text.TextField */;

        /* internal */ /* var */_str: string;
    }
